﻿using System;
using System.Collections.Generic;
using System.Text;
using DALFactory.DataBase;
using AppToolKit.Core.Context.Spring;
using System.Data;
using Utility;

namespace BLL.Business
{
    [AutoWiring]
    public  class TaskBusinessDao
    {
        [AutoWiring]
        public AccessHelper AccessHelperHolder { get; set; }

        public DataSet GetTaskDetailList(string taskId,string hotelid)
        {
            string strSql = string.Format("select  isnull(a.[choose],'false')  choose  ,t.* from task t LEFT OUTER JOIN allotment a "
+ "on t.code=a.task_code and a.tasklist_code='{0}' and a.hotelid='{1}'", taskId,hotelid);

            return AccessHelperHolder.GetDataSet(CommandType.Text, strSql);
        }
        public DataSet GetTask(string taskID,List<string> hotel)
        {
            string strSql = string.Format("select * from task t,grp_base_hotel h where t.code='{0}' and h.hotelid in ({0})", taskID, StringHelper.ListToString(hotel));
            return AccessHelperHolder.GetDataSet(CommandType.Text, strSql);
        }

        internal DataSet GetDistinctTask()
        {
            string strSql = "select distinct   task_code from allotment";
            return AccessHelperHolder.GetDataSet(CommandType.Text, strSql);
        }

        internal DataSet GetTask(string taskListId)
        {
            string strSql = string.Format("select * from task t,allot_task a,grp_base_hotel h,allot_tasklist al where t.code=a.task_code and al.hotelid=h.hotelid and al.tasklist_code=a.tasklist_code and a.tasklist_code='{0}' and t.halt='False' order by a.id", taskListId);
            return AccessHelperHolder.GetDataSet(CommandType.Text, strSql);
        }
    }
}
